package com.ruoyi.project.bid.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bid.domain.CustomerDetail;
import com.ruoyi.project.bid.service.ICustomerDetailService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
//import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 对接客户的明细Controller
 * 
 * @author ruoyi
 * @date 2023-11-27
 */
@Api(tags = "客户进度跟踪")
@RestController
@RequestMapping("/customer/detail")
public class CustomerDetailController extends BaseController
{
    @Autowired
    private ICustomerDetailService customerDetailService;

    /**
     * 查询对接客户的明细列表
     */
    @ApiOperation("对接历史")
//    @PreAuthorize("@ss.hasPermi('project:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerDetail customerDetail)
    {
        startPage();
        List<CustomerDetail> list = customerDetailService.selectCustomerDetailList(customerDetail);
        return getDataTable(list);
    }

    /**
     * 导出对接客户的明细列表
     */
//    @PreAuthorize("@ss.hasPermi('project:detail:export')")
    @Log(title = "对接客户的明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustomerDetail customerDetail)
    {
//        List<CustomerDetail> list = customerDetailService.selectCustomerDetailList(customerDetail);
//        ExcelUtil<CustomerDetail> util = new ExcelUtil<CustomerDetail>(CustomerDetail.class);
//        return util.exportExcel(list, "detail");
        return null;
    }

    /**
     * 获取对接客户的明细详细信息
     */
    @ApiOperation("记录详情")
//    @PreAuthorize("@ss.hasPermi('project:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(customerDetailService.selectCustomerDetailById(id));
    }

    /**
     * 新增对接客户的明细
     */
    @ApiOperation("新增记录")
//    @PreAuthorize("@ss.hasPermi('project:detail:add')")
    @Log(title = "对接客户的明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerDetail customerDetail)
    {
        customerDetail.setCreateBy(SecurityUtils.getUsername());
        return toAjax(customerDetailService.insertCustomerDetail(customerDetail));
    }

    /**
     * 修改对接客户的明细
     */
    @ApiOperation("修改记录")
//    @PreAuthorize("@ss.hasPermi('project:detail:edit')")
    @Log(title = "对接客户的明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerDetail customerDetail)
    {
        customerDetail.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(customerDetailService.updateCustomerDetail(customerDetail));
    }

    /**
     * 删除对接客户的明细
     */
    @ApiOperation("删除记录")
//    @PreAuthorize("@ss.hasPermi('project:detail:remove')")
    @Log(title = "对接客户的明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerDetailService.deleteCustomerDetailByIds(ids));
    }
}
